import Vue from 'vue'
import VueRouter from 'vue-router'
import store from '../store/index.js'
import flims from '../views/films.vue'

Vue.use(VueRouter)




const routes = [{
    path: '/Films',
    name: 'Films',
    component: flims
  },
  {
    path: '/cinemas',
    name: 'cinemas',
    component: () => import( /* webpackChunkName: "cinemas" */ '../views/cinemas.vue')
  },
  {
    path: '/mzact',
    name: 'mzact',
    component: () => import( /* webpackChunkName: "mz-act" */ '../views/mz-act.vue')
  },
  {
    path: '/center',
    name: 'center',
    component: () => import( /* webpackChunkName: "center" */ '../views/center.vue')
  },
  {
    path: '/self',
    name: 'self',
    component: () => import( /* webpackChunkName: "self" */ '../components/myPayment/Self.vue')
  },
  //   film这是单个电影页面得路由 只需要写一个就可以 
  {
    path: '/film',
    name: 'film',
    component: () => import( /* webpackChunkName: "filmIdView" */ '../components/filmChild/filmIdView.vue')
  },
  /*从影院页面跳转过去的 影院界面的分列1 关于list的 */
  {
    path: '/CinemaList',
    name: 'CinemaList',
    component: () => import( /* webpackChunkName: "CinemaList" */ '../components/CinemaChild/CinemaList.vue')
  },
  /* 选择全国列表   查找 a-z 的列表全国*/ 
  {
    path: '/searchCityList',
    name: 'searchCityList',
    component: () => import( /* webpackChunkName: "searchCityList" */ '../components/CityChild/searchCityList.vue')
  },
 /* 选座购票  界面  这个界面包括 片名 和 你当前地址的所有影院信息 （按日期排序）*/  
  {
    path: '/CinemaDetails',
    name: 'CinemaDetails',
    component: () => import( /* webpackChunkName: "CinemaDetails" */ '../components/CinemaChild/CinemaDetails.vue')
  },
  {
    path: '/noCinemas',
    name: 'noCinemas',
    component: () => import( /* webpackChunkName: "noCinemas" */ '../components/CinemaChild/noCinemas.vue')
  },

  /*查找影院searchCinemas*/ 
  {
    path: '/searchCinemas',
    name: 'searchCinemas',
    component: () => import( /* webpackChunkName: "searchCinemas" */ '../components/CityChild/searchCinemas.vue')
  },
  {
    path:"/ChoseSeat",
    name:"ChoseSeat",
    component: () => import( /* webpackChunkName: "searchCinemas" */ '../components/myPayment/ChoseSeat.vue')
  },
  {
    path: '*',
    redirect: '/Films'
  },
]







const router = new VueRouter({
  routes
})
// 全局路由守卫 设置
/* 每次跳转回到页面都给他加回来 导航栏*/
router.beforeEach((to, from, next) => {
  
  for (let i = 0; i < to.matched.length; i++) {
    if (to.matched[i].path === "/Films" || to.matched[i].path === "/cinemas"  || to.matched[i].path === "/center") {
      store.commit("setShow", true)
    }else{
      store.commit("setShow", false)
    }
  }
  // console.log(to,"这是路由");
  next();
})



export default router